//
//  UIView+Convenience.m
//  PCCategoriesDemo
//
//  Created by 宋鹏程 on 14-4-8.
//  Copyright (c) 2014年 宋鹏程. All rights reserved.
//

#import "UIView+Convenience.h"

@implementation UIView (Convenience)

- (CGPoint)frameOrigin
{
	return self.frame.origin;
}

- (void)setFrameOrigin:(CGPoint)newOrigin
{
	self.frame = CGRectMake(newOrigin.x, newOrigin.y, self.frameWidth, self.frameHeight);
}

- (CGSize)frameSize
{
	return self.frame.size;
}

- (void)setFrameSize:(CGSize)newSize
{
	self.frame = CGRectMake(self.frameX, self.frameY, newSize.width, newSize.height);
}

- (CGFloat)frameX
{
	return self.frame.origin.x;
}

- (void)setFrameX:(CGFloat)newX
{
	self.frame = CGRectMake(newX, self.frameY, self.frameWidth, self.frameHeight);
}

- (CGFloat)frameY
{
	return self.frame.origin.y;
}

- (void)setFrameY:(CGFloat)newY
{
	self.frame = CGRectMake(self.frameX, newY, self.frameWidth, self.frameHeight);
}

- (CGFloat)frameWidth
{
	return self.frame.size.width;
}

- (void)setFrameWidth:(CGFloat)newWidth
{
	self.frame = CGRectMake(self.frameX, self.frameY, newWidth, self.frameHeight);
}

- (CGFloat)frameHeight
{
	return self.frame.size.height;
}

- (void)setFrameHeight:(CGFloat)newHeight
{
	self.frame = CGRectMake(self.frameX, self.frameY, self.frameWidth, newHeight);
}

- (CGFloat)frameRight
{
	return self.frameX + self.frameWidth;
}

- (void)setFrameRight:(CGFloat)newRight
{
	self.frame = CGRectMake(newRight - self.frameWidth, self.frameY, self.frameWidth, self.frameHeight);
}

- (CGFloat)frameBottom
{
	return self.frameY + self.frameHeight;
}

- (void)setFrameBottom:(CGFloat)newBottom
{
	self.frame = CGRectMake(self.frameX, newBottom - self.frameHeight, self.frameWidth, self.frameHeight);
}

- (BOOL)containsSubView:(UIView *)subView
{
    for (UIView *view in [self subviews]) {
        if ([view isEqual:subView]) {
            return YES;
        }
    }
    return NO;
}

- (BOOL)containsSubViewOfClassType:(Class)subClass
{
    for (UIView *view in [self subviews]) {
        if ([view isMemberOfClass:subClass]) {
            return YES;
        }
    }
    return NO;
}

@end
